<template>
	<div>
		<!-- 搜索材料 -->
		<div style="margin-top: 10%;">
			<van-field :value="material_name" center clearable placeholder="材料搜索" :use-button-slot="true"
				left-icon="search" :border="false" @input="material_name_input">
			</van-field>
		</div>
		<!-- 材料列表 -->
		<div>
			<div v-for="(item, index) in materials" :key="index" style="margin-top: 5%;"
				@click="warehouse_detail(item)">
				<div style="display: flex;justify-content: space-around;width: 100%;">
					<div style="width: 70%;margin-left: 10%;">
						<div>
							{{ item.materialName }}-{{ item.equimentSource }}-{{ item.equimentManu }}
						</div>
						<div style="font-size: 25rpx;margin-top: 3%;">
							<span style="color: #9D9C9C;">规格型号:</span>
							<span style="color: #F5742D;margin-left: 3%;">{{ item.materialModel }}</span>
						</div>
					</div>
					<div style="width: 30%;margin-top: 5%;font-size: 38rpx;color: #479AF8;margin-left: 15%;">
						× {{item.equimentNum}}
					</div>
				</div>
				<van-divider />
			</div>
		</div>
	</div>
</template>

<script>
	import { BaseUrl } from '@/util/util.js';
	const PrefixUrl = BaseUrl();
	export default {
		data(){
			return{
				material_name: '',
				materials: [],
			}
		},
		onLoad: function(option) {},
		onShow(){
			this.get_all_material()
		},
		// created() {
		// 	this.get_all_material()
		// },
		methods:{
			get_all_material(){
				uni.request({
					method: 'POST',
					url: PrefixUrl + '/equimentQrcode/getQrcodeByBdst',
					data: {
						bdst: uni.getStorageSync('userbdst'),
						material_name: this.material_name,
						material_model: ''
							
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'token': uni.getStorageSync('token')
					},
					success: (res) => {
						this.materials = res.data.obj;
					}
				});
			},
			material_name_input(event) {
				this.material_name = event.detail;
				uni.request({
					method: 'POST',
					url: PrefixUrl + '/equimentQrcode/getQrcodeByBdst',
					data: {
						bdst: uni.getStorageSync('userbdst'),
						material_name: this.material_name
			
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'token': uni.getStorageSync('token')
					},
					success: (res) => {
						this.materials = res.data.obj;
					}
				});
			},
			warehouse_detail(item){
				console.log(item)
				uni.navigateTo({
					url: '/pages/equipment/ware/ware_select?id=' + item.id +
						'&name=' + item.materialName + '&model=' + item.materialModel + 
						'&equimentSource=' + item.equimentSource + '&equimentManu=' + item.equimentManu +
						'&materialCode=' + item.materialCode + '&materialCess=' + item.materialCess + 
						'&materialMoney=' + item.materialMoney
				});
			}
		}
	} 
</script>

<style>
</style>